<!-- video -->
<template>
  <div class="ai-video">
    <div class="left bg-#F5F9FF rounded-tr-16px">
      <el-scrollbar height="100%" class="w-full">
        <div class="modal-switch-container">
          <Common
            v-if="selectPlatform === 'common'"
            ref="commonRef"
            :models="models"
            @on-draw-complete="handleDrawComplete"
          />
        </div>
      </el-scrollbar>
    </div>
    <div class="main">
      <VideoList ref="videoListRef" @on-regeneration="handleRegeneration" />
    </div>
  </div>
</template>

<script setup lang="ts">
import VideoList from './components/VideoList.vue'
// import { AiPlatformEnum } from '@/views/ai/utils/constants'
import { VideoVO } from '@/api/ai/video'
import Common from './components/common/index.vue'
import { ModelApi, ModelVO } from '@/api/ai/model/model'
import { AiModelTypeEnum } from '@/views/ai/utils/constants'

const videoListRef = ref<any>() // video 列表 ref
const commonRef = ref<any>() // stable diffusion ref

// 定义属性
const selectPlatform = ref('common') // 选中的平台

const models = ref<ModelVO[]>([]) // 模型列表

/** 绘画 complete */
const handleDrawComplete = async (platform: string) => {
  await videoListRef.value.getVideoList()
}

/** 重新生成：将画图详情填充到对应平台 */
const handleRegeneration = async (video: VideoVO) => {
  // 切换平台
  selectPlatform.value = video.platform
  // 根据不同平台填充 video
  await nextTick()
  // ...暂无该功能
}

/** 组件挂载的时候 */
onMounted(async () => {
  // 获取模型列表
  models.value = await ModelApi.getModelSimpleList(AiModelTypeEnum.VIDEO)
})
</script>

<style scoped lang="scss">
.ai-video {
  position: absolute;
  inset: 0;
  display: flex;
  width: 100%;
  height: 100%;
  flex-direction: row;
  column-gap: 12px;

 .left {
    display: flex;
    width: 338px;

    .segmented .el-segmented {
      --el-border-radius-base: 16px;
      --el-segmented-item-selected-color: #fff;

      width: 350px;
      background-color: #ececec;
    }

    .modal-switch-container {
      padding: 10px;
      flex-direction: column;
    }
  }

  .main {
    flex: 1;
  }

  .right {
    width: 350px;
    background-color: #f7f8fa;
  }
}
</style>
